Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 1 - Introduction to Finder Scripting


Recording Actions in the Finder

You can record almost any actions in the Finder that involve manipulating Finder windows or icons: for example, opening folders, copying files, or changing View settings. To record actions in the Finder, click the Record button in the Script Editor application, then activate the Finder (by clicking on the desktop or choosing Finder from the Applications menu) and perform the actions that you want to record.

For example, suppose you like to have certain Finder windows arranged next to each other on the desktop when you're working on financial matters, so
that related files, alias files, or applications are easily accessible. To record the arrangement you want, follow these steps:

  1. Open the Script Editor application.
  2. Click the Record button.
  3. Activate the Finder by clicking on the desktop or choosing Finder from the Applications menu.
  4. If any Finder windows are currently open, close them all by holding down the Option key and clicking the close box of the active window.
  5. Open, resize, and arrange the windows whose positions you want
    to record.
  6. When you're satisfied with the arrangement of the desktop, activate the Script Editor again and click the Stop button.

The recorded script should look something like the one in Listing 1-1 on page 5.

If you save your recorded script as a script application, you can arrange the windows the same way at any time by double-clicking the script's icon in the Finder. The Finder responds by closing any windows that are currently open and opening and arranging windows as specified in the script.

Listing 1-1 A sample recorded script

tell application "Finder"   activate
   close every window
   select startup disk
   open selection
   set position of window of startup disk to {4, 43}
   set size of window of startup disk to {369, 464}
   select folder "Financial" of startup disk
   open selection
   set position of window of folder "Financial" of startup disk to ¬
      {378, 43}
   set size of window of folder "Financial" of startup disk to ¬
      {200, 155}
   select folder "Letters" of startup disk
   open selection
   set size of window of folder "Letters" of startup disk to ¬
      {257, 385}
   set position of window of folder "Letters" of startup disk to ¬
      {379, 222}
   set size of window of folder "Letters" of startup disk to ¬
      {200, 286}
end tell

Subtopics
Modifying Recorded Scripts
Simplifying Recorded Scripts

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996